const App = {
    mixins: [Save],//配置文件，路径/utils/mixins.js
    data() {
        return {
            dataForm:{
                Summarize:'',
            },
            innovation_mechanism: [],
            personal_information:[],
            fileList:[],
            childDataForm:[],
            isfirst:true,
        };
    },
    mounted() {
        this.getCategory();
    },
    watch:{
        'dataForm.Innovation_Practice_SerialNumber'(val) {
            this.handleChange(this.dataForm.Innovation_Mechanism_SerialNumber)
        },
        childDataForm(val) {
            if (this.action == 'Modify'&&this.isfirst) {
                let arr = [];
                val.forEach(item => {
                    item.name = item.Attachment_Name + "（磁盘文件名:"+item.Attachment_URL+"）" 
                    arr.push(item)
                })
                this.fileList = arr;
                this.isfirst = false;
            }
        }
    },
    methods: {
        getCategory() {
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryByTableName`,
                type: "POST",
                data: {
                    Data: 'innovation_mechanism',
                    Condition: "Row_Status='0'",
                },
                success: (data) => {
                    this.innovation_mechanism = data; // 直接使用 this
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest);
                },
                dataType: "json",
            });
        },
        handleChange(val){
            $.ajax({
                headers: requestHeaders(),
                url: `${mh}/generalBusiness/generalQueryBySQLSerialNumber`,
                method: "post",
                data: {
                    SQLSerialNumber: 't_innovation_mechanism_member',
                    Condition: '',
                    ExtensionCondition: window.btoa(unescape(encodeURIComponent("AND innovation_mechanism.Innovation_Mechanism_SerialNumber='" + val + "'"))),
                },
                success: (data) => {
                    this.personal_information = data;
                    if (data.length == 0) {
                        this.$message({
                            message: '暂无可选实践人',
                            type: 'warning'
                        })
                    }
                },
                complete: (XMLHttpRequest) => {
                    requestPretreatment(XMLHttpRequest)
                },
            })
        },
        success(row, res) {
            this.childDataForm.push({
                uid: row.uid,
                Innovation_Practice_SerialNumber:this.dataForm.Innovation_Practice_SerialNumber,
                Attachment_URL: res.fileName,
                Attachment_Name:row.name,
                Temp_Path:res.tempPath
            })
        },
        remove(row) {
            if (!Object.keys(row).some(item => item.includes('_Original'))) {
                this.childDataForm = this.childDataForm.filter(i => i.uid != row.uid);
            } else {
                let obj = this.childDataForm.filter(i => i.Attachment_SerialNumber == row.Attachment_SerialNumber)[0];
                obj.Row_Status = '1'
            }
        },
    },
};
const { createApp, ref } = Vue;
const app = createApp(App);
app.use(ElementPlus,{locale: zhCn});
//这种方式是引入全部图标，无需单个引入
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component);
}
app.component('yl-upload', ylUpload);
app.component('yl-text-editor', ylTextEditor);
app.component('yl-select', ylSelect);
const ElMessage = ElementPlus.ElMessage;
app.mount("#app");
